#ifndef __BUFFER_STREAM_H__
#define __BUFFER_STREAM_H__

class BufferStream
{
public:
	BufferStream(void){};
	virtual ~BufferStream(void){};
};

class BufferOutStream:public BufferStream
{
protected:
	int mbFree;
	char * mData;
	int mSize;
public:
	BufferOutStream(int nSize=0);
	void Attach(int nSize);
	void Attach(char * buffer,int nSize);
	void Release();
	virtual ~BufferOutStream();
	virtual void PutQ(const char * p )=0;
	virtual void Put(const char * fmt,...)=0;

	char * GetHead(){ return mData; }
	int GetSize() { return mSize; }
};

class StringOutter: public BufferOutStream
{
protected:
	int mLast;
public:
    StringOutter();
	virtual ~StringOutter(){};

	int GetLength() { return mLast; }
	void Clear();


	virtual void PutQ(const char * p);
	virtual void Put(const char * fmt,...);
};

class KeyPairOutter:public StringOutter
{
public:
     KeyPairOutter();
	 virtual ~KeyPairOutter();
	 void PutKey(const char * key,const char * value,char conn);
	 void PutKeyQ(const char * key,const char * value,char conn);
	 void PutKeyEncode(const char * key,const char * value,char conn);
};

#endif

